package com.example.rabbitmq.starter.entity;

import com.example.rabbitmq.starter.util.JpaJsonConverter;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;
import java.util.Date;
import java.util.Map;

/**
 * 失败消息信息实体类
 */
@Data
@Entity
@Table(name = "failed_message_info")
public class FailedMessageInfo {

    @Comment("失败消息ID")
    @Id
    private String id;

    @Comment("消息ID")
    @Column(unique = true)
    private String messageId;

    @Comment("业务ID")
    private String businessId;

    @Comment("消息类型")
    private String messageType;

    @Comment("交换机名称")
    private String exchangeName;

    @Comment("路由键")
    private String routingKey;

    @Comment("队列名称")
    private String queueName;

    @Comment("消息内容(JSON格式)")
    @Column(columnDefinition = "TEXT")
    private String messageContent;

    @Comment("消息属性")
    @Convert(converter = JpaJsonConverter.class)
    @Column(columnDefinition = "TEXT")
    private Map<String, Object> messageProperties;

    @Comment("失败原因")
    @Column(columnDefinition = "TEXT")
    private String failReason;

    @Comment("失败时间")
    @Temporal(TemporalType.TIMESTAMP)
    private Date failTime;

    @Comment("重试次数")
    private int retryCount;

    @Comment("最大重试次数")
    private int maxRetryCount;

    @Comment("上次重试时间")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastRetryTime;

    @Comment("状态：待处理、已重试、已忽略")
    private String status;

    @Comment("处理结果")
    @Column(columnDefinition = "TEXT")
    private String processResult;

    @Comment("持久化文件路径")
    private String filePath;

    @Comment("创建时间")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    @Comment("更新时间")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;
}